package server

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"github.com/hibiken/asynq"
)

// SchedulerServer 定時任務
type SchedulerServer struct {
	Server *asynq.Scheduler
}

func NewSchedulerServer(server *asynq.Scheduler) *SchedulerServer {
	return &SchedulerServer{
		Server: server,
	}
}

func (s *SchedulerServer) Start(ctx context.Context) error {
	log.Info("scheduler server start")
	return s.Server.Run()
}

func (s *SchedulerServer) Stop(ctx context.Context) error {
	log.Info("scheduler server stop")
	s.Server.Shutdown()
	return nil
}
